@extends('layouts.admin')
@section('title')
    <title>usubscribe列表</title>
@endsection
@section('content')
    @include('layouts.left')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
               usubscribe列表
                <small>Control panel</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Dashboard</li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">


                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title"><a type="button" class="btn btn-block btn-success" href="{{ url('mycoupon') }}/create">添加usubscribe信息</a></h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>id</th>
                                    <th>店铺名称</th>
                                    <th>用户电话</th>
                                    <th>用户开始时间</th>
                                    <th>用户结束时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody class="mparent">
                                @foreach($datas as $data)
                                        <tr>
                                            <td><input type="checkbox" value="{{$data -> id}}" name="usubscribe[]"></td>
                                            <td>{{$data -> id}}</td>
                                            <td>{{ $data -> shopname}}</td>
                                            <td>{{ $data -> mobile }}</td>
                                            <td><?php echo date('Y-m-d',$data -> starttime); ?></td>
                                            <td><?php echo date('Y-m-d',$data -> endtime); ?></td>
                                            <td>
                                            @if($data -> substatus == '0')
                                                no order
                                            @elseif($data -> substatus == '1')
                                                reject order
                                            @elseif($data -> substatus == '2')
                                                accept order
                                            @else
                                                complete
                                            @endif
                                            </td>
                                            <td><a href="{{ url('usubscribe') }}/{{ $data -> id }}"><i class="fa fa-reorder"></i></a>　　<a href="javascript:;" onclick="usubscribe_delete(this,{{ $data -> id }})"><i class="fa fa-trash-o"></i></a></td>
                                        </tr>
                                @endforeach
                                </tbody>

                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                </div>
                {{ $datas -> links() }}
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <!-- 在这里 写js函数-->
    <script type="text/javascript">
        function usubscribe_delete(e,id){
            $.ajaxSetup({
                headers:{
                    'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
                }
            });
            var tr = $(e).closest("tr");
            if(confirm("确定要删除此条数据吗？"))
                $.ajax({
                    url:"{{ url('usubscribe') }}/"+id,
                    type:"DELETE",
                    data:{id:id},
                    success:function(data){
                        if(data.status == 'success'){
                            alert(data.msg);
                            tr.remove();

                        }else{
                            alert(data.msg);
                        }
                    },
                    dataType:'json'
                });
        }
    </script>
@endsection


